package com.island.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.island.dao.ContentDao;
import com.island.model.Content;
import com.pollexsoft.base.dao.EntityDao;
import com.pollexsoft.base.service.BaseService;

@Service
public class ContentService extends BaseService<Content, java.lang.String>{
	
	@Autowired
	private ContentDao contentDao;
	
	@Override
	protected EntityDao getEntityDao() {
		// TODO Auto-generated method stub
		return this.contentDao;
	}
	/**
	 * 查询全部内容
	 * @return
	 */
	public List<Content> findAllContent(){
		return contentDao.findAll();
	}
	
	/**
	 * 根据ID查询内容
	 * @param id
	 * @return
	 */
	public Content findContentByID(String id){
		Content content = null;
		List<Content> conList = this.find("from Content where content_id="+id);
		if(conList!=null&&conList.size()>0){
			content = conList.get(0);
		}
		return content;
	}
	
	
	/**
	 * 创建内容
	 * @param content
	 */
	public void createContent(Content content){
		contentDao.insertContent(content);
	}
	
	/**
	 * 修改内容
	 * @param content
	 */
	public void updateContent(Content content){
		contentDao.updateContent(content);
	}
	
	/**
	 * 根据ID删除内容
	 * @param id
	 */
	public void deleteContent(int id){
		contentDao.delContent(id);
	}
}
